aboutsummaryrefslogtreecommitdiff
path: root/src/pages/board/[board].astro
blob: 2624fed18aa5e8bbda693462d27beae35d859e82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
---
import Default from '../../layouts/Default.astro';
import Thread from '../../components/Thread.svelte'
import type Thread from '../../models/Thread';

import { api } from '../../lib/api.ts';
import { processThreadIn } from '../../lib/thread'

const { board } = Astro.params;
const data = await api('get', `board/${board}`);

if(data.status === 404) return Astro.redirect('/404');

const threads: Thread[] = await data.json();
for(let thread of threads)
  await processThreadIn(board, thread);
---

<Default>
  <h1><a href="/boards"> {board} </a></h1>

  {threads.map((thread) => (
    <Thread thread={thread} board={board} />
  ))}

</Default>